//
//  Record.swift
//  ImGuider X
//
//  Created by llt on 2018/9/14.
//  Copyright © 2018年 imguider. All rights reserved.
//

import UIKit
import CoreLocation

class Record: NSObject, Codable {

    var id,spotname,ename,playpath,spotpictures,keywords,lat,lng,nodenumber:String?
    var number:Int?
    var autoplay:Int?
    var autoplayrange:Int?
    var transport:TransportType?
    
    var pictureArray:[String]? {
        
        return spotpictures?.components(separatedBy: ",").compactMap({ str -> String? in
            
            return str.count > 0 ? str : nil
        })
    }
    
    var coor:CLLocationCoordinate2D? {
        
        guard let lat = lat, let lat1 = Double(lat),let lng = lng, let lng1 = Double(lng) else {
            
            return nil
        }
        
        let coor = CLLocationCoordinate2D(latitude: lat1, longitude: lng1)
        
        if CLLocationCoordinate2DIsValid(coor) {
            
            return coor
        }
        
        return nil
    }
}
